/*class Solution {
public:
    TreeNode* convert(vector<int>& preorder, vector<int>& inorder, int& index, int begin, int end)
    {
        TreeNode* root = nullptr;
        if (index >= preorder.size())
        {
            return root;
        }
        root = new TreeNode(preorder[index]);
        int mid = begin;
        while (mid < end)
        {
            if (inorder[mid] != preorder[index])
                mid++;
            else
                break;
        }
        if (begin < mid)
            root->left = convert(preorder, inorder, ++index, begin, mid);
        if (mid + 1 < end)
            root->right = convert(preorder, inorder, ++index, mid + 1, end);
        return root;
    }
    TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
        int index = 0;
        TreeNode* head = convert(preorder, inorder, index, 0, inorder.size());
        return head;
    }
};*/